package com.xuliugen.javamybatis.demo.proxy.dynamicproxy2;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;

/**
 * Created by xuliugen on 2017/11/9.
 */
public class MapperProxy<T> implements InvocationHandler {

    private Class<T> target;

    public MapperProxy(Class<T> target) {
        this.target = target;
    }

    @Override
    public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {

        System.out.println("----before-----");


        System.out.println("----end-----");

        return new Object();
    }

    public Object getProxyInstance() {
        return Proxy.newProxyInstance(Thread.currentThread().getContextClassLoader(), new Class[]{target}, this);
    }
}
